package Test3;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class PhoneTest {
    public static void main(String[] args) {
        ArrayList<Phone> list = new ArrayList<>();
        Phone p1 = new Phone("小米",3999);
        Phone p2 = new Phone("华为",5999);
        Phone p3 = new Phone("魅族",4999);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        ArrayList<Phone> list1 = result(list);
        for (int i = 0; i < list1.size(); i++) {
            System.out.println(list1.get(i).getBrand() +" "+ list1.get(i).getPrice());
        }
    }
    public static ArrayList<Phone> result(ArrayList<Phone> list){
        ArrayList<Phone> result = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getPrice() < 5000){
                result.add(list.get(i));
            }
        }
        return result;
    }
}